package com.googlecode.groovy_toy_orm

/**
 * To be used by complexQueryBuilder()
 * @author: DavydovMD
 * Date: 24.04.13
 * Time: 17:12
 */

//TODO: Implement!
class QueryBuildingMapper<T> extends MultiTableMapper<T> {
    MultiTableMapper<T> mainMapper

    QueryBuildingMapper(List<MultiTableMapper> mappers, List<MapperBinding> bindings) {
        super(mappers.first().mappers, mappers.first().beanClass, mappers.first().mapperBindingsParameter)
        mainMapper = mappers.first()


        mappers.each {
            if (it!=mainMapper){
                this.mappers.addAll(it.mappers)
            }
        }

        bindings.each {
            it.locateMapper(this.mappers as List<SingleDbTableMapper>)
            mapperBindings.put it.mapper as SingleDbTableMapper, it
        }

        //TODO: change unmarshaller type (single/multi) if needed


    }

    @Override
    List<Field> getAllFields() {
        mainMapper.getAllFields()
    }


}
